package com.example.module_maintenance

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.lib_base.path.RouterPath
import com.bw.lib_base.view.BaseActivity
import com.example.module_maintenance.adapter.CultureAdapter
import com.example.module_maintenance.databinding.ActivityCultureBinding
import com.example.module_maintenance.viewmodel.CultureViewModel
import com.example.module_maintenance.viewmodel.MaintenanceViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
@Route(path = RouterPath.PATH_CULTURE_ACTIVITY)
class CultureActivity : BaseActivity<ActivityCultureBinding>() {
    private val vm by lazy { ViewModelProvider(this)[CultureViewModel::class.java] }


    private val cultureAdapter by lazy { CultureAdapter() }

    override fun initView() {
        mDataBinding.whRv.adapter = cultureAdapter
        mDataBinding.whRv.layoutManager = LinearLayoutManager(this)
        vm.getCulture()

        vm.getCultureSuccess.observe(this){
            cultureAdapter.data.clear()
            cultureAdapter.data.addAll(it)
            cultureAdapter.notifyDataSetChanged()
        }

        mDataBinding.back.setOnClickListener {
            finish()
        }


        mDataBinding.addwh.setOnClickListener {

             ARouter.getInstance().build(RouterPath.PATH_ADD_CULTURE_ACTIVITY).navigation()

        }
    }






    override fun getLayoutId(): Int  = R.layout.activity_culture


}